<template>
  <el-switch
    v-model="form.enabled"
    active-color="#13ce66"
    inactive-color="#ff4949"
    active-value="true"
    inactive-value="false">
  </el-switch>
</template>

<script>
export default {
  name: 'ElSwitch',
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeToEdit](crud, form){
      form.enabled=form.enabled+"";
    }
  }
}
</script>

<style scoped>

</style>
/***
片段
【1】crud，toedit使用报错，js错误：不能有Boolean值
【2】开关的使用
[Vue warn]: Invalid prop: type check failed for prop "value". Expected String, Number, got Boolean with value false.

found in

---> <ElInput> at packages/input/src/input.vue
<ElFormItem> at packages/form/src/form-item.vue
  <ElForm> at packages/form/src/form.vue
    <ElDialog> at packages/dialog/src/component.vue
      <CourseCategory>
        <Layout2> at src/layout/Layout2.vue
          <AppMain> at src/layout/components/AppMain.vue
            <Layout> at src/layout/index.vue
              <App> at src/App.vue
                <Root>
                  warn @ vue.runtime.esm.js:619
                  ...
                  resetForm @ crud.js:539
                  toEdit @ crud.js:227
                  click @ UD.operation.vue?1403:83
                  invokeWithErrorHandling @ vue.runtime.esm.js:1854
                  invoker @ vue.runtime.esm.js:2179
                  invokeWithErrorHandling @ vue.runtime.esm.js:1854
                  Vue.$emit @ vue.runtime.esm.js:3882
                  handleClick @ element-ui.common.js:9441
                  invokeWithErrorHandling @ vue.runtime.esm.js:1854
                  invoker @ vue.runtime.esm.js:2179
                  original._wrapper @ vue.runtime.esm.js:6911
                  Show 22 more frames

**/
